#ifndef SCENEMANAGER_H
#define SCENEMANAGER_H

#include "d3dUtil.h"

//tool stuff
#include "Logger.h"


#include "GlobalMessage.h"

#include "ResourcesManager.h"

//mesh stuff
#include "Bone.h"
#include "Face.h"
#include "VertexWeight.h"
#include "MaterialInfo.h"
#include "Mesh.h"

#include "SceneNode.h"
#include "Camera.h"

#include "VertexFormat.h"
#include "LightEffects.h"

class SceneManager
{
public:
	SceneManager(void);
	~SceneManager(void);

	//initialize the scene manager
	void		Init(ID3D10Device* device);

	//add an object into the scene
	void		AddObject(SceneNode* objNode);

	//get the object root node by name,return null if the object not exist
	SceneNode*	GetObjectByName(const std::string& name);

	//begin from the parent,update the node hierarchy
	void		UpdateNodeWorldTransform(SceneNode* parent);

	//render all the node in the scene
	void		RenderOneFrame();

	//get the scene root node
	SceneNode*	GetSceneRootNode();

	//set a light
	void		SetLight(const Light& _light);

	//determine if a node has mesh intersect with a ray
	bool		IntersectWithNode(SceneNode* pNode,Ray ray);

	//destroy one node and it's children
	bool		DestroyNode(SceneNode* pNode);
private:
	inline void DrawMesh(Mesh* mesh);
	inline void DrawSceneNode(SceneNode* node);

private:
	ID3D10Device*						m_pDevice;
	SceneNode*							m_pSceneRootNode;
	std::map<std::string,SceneNode*>	m_mapObject;
	Effect::LightEffects				m_ParalleLightEffect;

	Light								m_Light;
};

#endif


